**************************************************************************************************************************************************
****************************** Wealth-Income Ratios in Free Market Capitalism: Switzerland, 1900-2020 ********************************************
**************************************************************************************************************************************************
clear all
set more off
set scheme s1color  

**Author: Enea Baselgia and Isabel Z. Martinez
**Date: January, 25 2023

*** set this path to the current directory
*** global mypath "C:\Users\EBaselgia\Dropbox\WIR_project\Publication_process\replication"

***read data 
cd "$mypath/final_data/"
use "WIR_final.dta", clear
cd "$mypath/output/figures/"


******************* PRODUCES ALL APPENDIX FIGURES  ****************************************




*******************************************************************************************************************************
// generate a private WIR series for which we have actual observation from tax data (i.e. delete the interpolated datapoints)
gen ch_pWIR_mis = ch_pWIR
replace ch_pWIR_mis = . if year > 1900 & year < 1910 | year == 1911 | year == 1912 | year == 1914 | year > 1915 & year < 1919 | year == 1920 | year > 1921 & year < 1925
replace ch_pWIR_mis = . if year > 1925 & year < 1929 | year > 1929 & year < 1934 | year == 1935 | year == 1937 | year == 1939 | year > 1941 & year < 1945
replace ch_pWIR_mis = . if year == 1946 | year == 1948| year == 1950|year == 1952| year == 1954 | year == 1956 | year > 1957 & year < 1969 | year > 1969 & year < 1981

tw (connect ch_pWIR_mis year if year>=1900, lcolor(gs1) msymb(Oh) mcolor(gs1) lpattern() lwidth(medthick)) ///
   (connect ch_pWIR_bruelhart year if year>=1900, lcolor(gs8) msymb(T) mcolor(gs8) lpattern(dash) lwidth(medthick) ) ///
, scheme(s1mono) title() legend(order(1 "own estimates" 2 "Brülhart et al. (2018)")) ytitle(Value of wealth (in % of national income)) xtitle("") ///
ylab(2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%" 8 "800%", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020, grid)

graph export "Fig_append_A_1.pdf", replace

*******************************************************************************************************************************

*******************************************************************************************************************************

*** Agricultural Land and other Domestic capital Germany, France, Italy, Sweden, United States
label variable DE_domW_agri_WIR "Germany"
label variable FR_domW_agri_WIR "France"
label variable IT_domW_agri_WIR "Italy"
label variable SE_domW_agri_WIR "Sweden"
label variable US_domW_agri_WIR "United States"

tw (connect DE_domW_agri_WIR year if year>=2000, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect FR_domW_agri_WIR year if year>=2000, lcolor(blue*1.2) mcolor(blue*1.2) msymb(Th) lpattern(-.-) lwidth(medthick)  ) ///
	(connect IT_domW_agri_WIR year if year>=2000, lcolor(green*1.2) mcolor(green*1.2) msymb(Oh) lpattern(-.-) lwidth(medthick)  ) ///
	(connect SE_domW_agri_WIR year if year>=2000, lcolor(orange*1.2) mcolor(orange*1.2) msymb(Dh) lpattern(longdash) lwidth(medthick)  ) ///
	(connect US_domW_agri_WIR year if year>=2000, lcolor(yellow*1.2) mcolor(yellow*1.2) msymb(D) lpattern(longdash) lwidth(medthick)  ) ///
	, title() legend() ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(0.2 "20%" 0.4 "40%" 0.6 "60%" 0.8 "80%" 1 "100%", grid) xlab(2000(5)2020,grid)

	graph export "Fig_append_A_2.pdf", replace

	
*******************************************************************************************************************************

*******************************************************************************************************************************

*** private wealth income ratios (exclusive and inclusive agricultural land and other domestic private wealth) 
***Germany
label variable DE_pWIR_excl_domW_agriW "excl. agriculture land and other domestic capital"
label variable DE_pWIR "incl. agriculture land and other domestic capital"
   

tw (line DE_pWIR year if year>=1900, lcolor(black*1.0) lwidth(medthick)  ) ///
 (line DE_pWIR_excl_domW_agriW year if year>=1900, lcolor(black*1.0) lpattern(-.-) lwidth(medthick)  ) ///
 , title() legend(size(small)) legend(label(1 "incl. agriculture land and" "other domestic capital") label(2 "excl. agriculture land and" "other domestic capital") size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(1 "100%" 2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020, grid)
graph export "Fig_append_A_3a.pdf", replace
    

***France
label variable FR_pWIR_excl_domW_agriW "excl. agriculture land and other domestic capital"
label variable FR_pWIR "incl. agriculture land and other domestic capital"
   
tw (line FR_pWIR year if year>=1900, lcolor(blue*1.2) lwidth(medthick)  ) ///
 (line FR_pWIR_excl_domW_agriW year if year>=1900, lcolor(blue*1.2) lpattern(-.-) lwidth(medthick)  ) ///
 , title() legend(size(small)) legend(label(1 "incl. agriculture land and" "other domestic capital") label(2 "excl. agriculture land and" "other domestic capital") size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(1 "100%" 2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020, grid)
graph export "Fig_append_A_3b.pdf", replace
    	
***Sweden
label variable SE_pWIR_excl_domW_agriW "excl. agriculture land and other domestic capital"
label variable SE_pWIR "incl. agriculture land and other domestic capital"
   
tw (line SE_pWIR year if year>=1900, lcolor(orange*1.2) lwidth(medthick)  ) ///
 (line SE_pWIR_excl_domW_agriW year if year>=1900, lcolor(orange*1.2) lpattern(-.-) lwidth(medthick)  ) ///
 , title() legend(size(small)) legend(label(1 "incl. agriculture land and" "other domestic capital") label(2 "excl. agriculture land and" "other domestic capital") size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(1 "100%" 2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020, grid)
graph export "Fig_append_A_3c.pdf", replace
    		
	
***United States
label variable US_pWIR_excl_domW_agriW "excl. agriculture land and other domestic capital"
label variable US_pWIR "incl. agriculture land and other domestic capital"
   
tw (line US_pWIR year if year>=1900, lcolor(yellow*1.2) lwidth(medthick)  ) ///
 (line US_pWIR_excl_domW_agriW year if year>=1900, lcolor(yellow*1.2) lpattern(-.-) lwidth(medthick)  ) ///
 , title() legend(size(small)) legend(label(1 "incl. agriculture land and" "other domestic capital") label(2 "excl. agriculture land and" "other domestic capital") size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(1 "100%" 2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020, grid)
graph export "Fig_append_A_3d.pdf", replace
    		
			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			

*** To produce Appendix Figure A4 (estimating the value of agricultural land through capitalization) run this do-file which performs the capitalization and produces the figure 
*** For details see the do-file below
cd "$mypath/"
do "5_analysis_wir_append_fig_agri_land.do"		
			
***read data 
cd "$mypath/final_data/"
use "WIR_final.dta", clear
cd "$mypath/output/figures/"
			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			
			
tw (connect ch_pWIR year if year>=2000, lcolor(red*1.0) msymb(O) mcolor(red*1.0) lwidth(medthick) ) ///
(connect ch_pWIR_bruelhart year if year>=1970, lcolor(black*1.0) msymb(T) mcolor(black*1.0) lpattern(longdash) lwidth(medthick) ) ///
(connect ch_pWIR_schmidt year if year>=1970, lcolor(navy) msymb(D) msize(1.3) mcolor(navy) lpattern() lwidth(medthick)  ) ///
, title() legend(order(1 "SNB (2020)" 2 "Brülhart et al. (2018)" 3 "Schmid (2013)") row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ///
ylab(2 "200%" 3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%" 8 "800%", grid) xlab(1970(10)2020,grid)

graph export "Fig_append_B_1.pdf", replace

*******************************************************************************************************************************			
			
*******************************************************************************************************************************			
clear all
cd "$mypath/raw_data/"

import excel "CH_taxW_panel.xlsx", sheet("panel") firstrow
keep if cantonid==0
rename w_total tax_wealth
keep year tax_wealth
cd "$mypath/final_data/"
merge 1:1 year using "WIR_final.dta"
keep if _merge==3

keep year ch_pW_T ch_pW_pension_T tax_wealth ch_nni_T ch_pWIR


gen sh_taxW_PW = tax_wealth / ch_pW_T
gen ch_pW_T_excl_pensW = ch_pW_T - ch_pW_pension_T
gen sh_taxW_PW_excl_pensW = tax_wealth / ch_pW_T_excl_pensW 

label var sh_taxW_PW "taxable wealth in % total private wealth (incl. pension wealth)"
label var sh_taxW_PW_excl_pensW "taxable wealth in % total private wealth (excl. pension wealth)"
	
	
cd "$mypath/output/figures/"
set scheme s1color

tw  (connect sh_taxW_PW year if year>=1980, lcolor(red) lpattern() lwidth(medthick) msize() mcolor(red) msymb(O) lwidth(medthick)) ///
	(connect sh_taxW_PW_excl_pensW year if year>=1980, lcolor(black) msize() mcolor(black) msymb(T) lwidth(medthick) ) ///
	, title() legend(row(2)) ytitle("taxable wealth in % total private wealth") xtitle("") ylab(0.4 "40%" 0.5 "50%" 0.6 "60%" 0.7 "70%" 0.8 "80%", grid)  ///
	xlabel(2003 "2003" 2006 "2006"  2009 "2009" 2012 "2012" 2015 "2015" 2018 "2018", grid)

	graph export "Fig_append_B_2a.pdf", replace


gen ch_tax_W_incPensionW = ch_pW_pension_T + tax_wealth
gen ch_tax_W_incPensionW_gr = ch_tax_W_incPensionW / ch_tax_W_incPensionW[_n-1] -1
gen ch_pW_T_gr = ch_pW_T / ch_pW_T[_n-1] -1
gen ch_taxW_gr = tax_wealth / tax_wealth[_n-1] -1


set scheme s1color
label var ch_pW_T_gr "Private wealth at market value (annual change in %)"
label var ch_tax_W_incPensionW_gr "Taxable wealth inc. pension wealth (annual change in %)"

pwcorr ch_tax_W_incPensionW_gr ch_pW_T_gr, sig
local corr = `r(rho)'
local corr : di %3.2f `corr'
display `corr'


tw  (connect ch_pW_T_gr year if year>=2004, lcolor(red) lpattern() lwidth(medthick) msize() mcolor(red) msymb(O) lwidth(medthick)) ///
	(connect ch_tax_W_incPensionW_gr year if year>=2004, lcolor(black) msize() mcolor(black) msymb(T) lwidth(medthick) ) ///
	, title() legend(row(2)) ytitle("%-change") xtitle("") ylabel(-0.05 "-5" 0.00 "0" 0.05 "5" 0.1 "10") ///
	xlabel(2003 "2003" 2006 "2006"  2009 "2009" 2012 "2012" 2015 "2015" 2018 "2018") ///
	ylab(, grid) xlab(, grid) yline(0, lcolor(black)) text(-0.025 2004 "{&rho}=`corr'", place(e))
	
	graph export "Fig_append_B_2b.pdf", replace
	pwcorr ch_taxW_gr ch_pW_T_gr, sig
	
	

*******************************************************************************************************************************			
			
*******************************************************************************************************************************			
***** Historical Estimates of Private Wealth: Figure		
***read data 
clear all
set scheme s1color
cd "$mypath/final_data/"
use "WIR_final.dta", clear
cd "$mypath/output/figures/"


*** Private WIR - Figures
// generate a private WIR series for which we have actual observation from tax data (i.e. delete the interpolated datapoints)
gen ch_pWIR_mis = ch_pWIR
label variable ch_pWIR_mis "Private Wealth-Income Ratio - only when acctual observation"
replace ch_pWIR_mis = . if year > 1900 & year < 1910 | year == 1911 | year == 1912 | year == 1914 | year > 1915 & year < 1919 | year == 1920 | year > 1921 & year < 1925
replace ch_pWIR_mis = . if year > 1925 & year < 1929 | year > 1929 & year < 1934 | year == 1935 | year == 1937 | year == 1939 | year > 1941 & year < 1945
replace ch_pWIR_mis = . if year == 1946 | year == 1948| year == 1950|year == 1952| year == 1954 | year == 1956 | year > 1957 & year < 1969 | year > 1969 & year < 1981


gen ch_pW_geering_hotz = 30000 if year==1912 | year==1913 | year==1914
gen ch_pW_landmann = 34600 if year==1913 
gen ch_pW_fahrlaender = 41960 if year==1913 
gen ch_pW_landmann_no_durable = ch_pW_landmann - 9900 if year==1913 
gen ch_pWIR_geering_hotz = ch_pW_geering_hotz / ch_nni_T
gen ch_pWIR_landmann = ch_pW_landmann / ch_nni_T
gen ch_pWIR_fahrlaender = ch_pW_fahrlaender / ch_nni_T
gen ch_pWIR_landmann_no_durable = ch_pW_landmann_no_durable / ch_nni_T

label var ch_pWIR_mis "own estimates"
label var ch_pWIR_bruelhart "Brülhart et al. (2018)"
label var ch_pWIR_geering_hotz "Geering and Hotz (1914)"
label var ch_pWIR_landmann "Landmann (1916)"
label var ch_pWIR_fahrlaender "Fahrländer (1919)"
label var ch_pWIR_landmann_no_durable "Landmann (1916); excl. moveable assets" 

tw (scatter ch_pWIR_mis year if year>=1910 & year<=1916, msymb(Oh) msize(medlarge) mcolor(red*1.0) ) ///
(scatter ch_pWIR_bruelhart year if year>=1910 & year<=1916, msymb(Th) msize(medlarge) mcolor(black*1.0) ) ///
(scatter ch_pWIR_geering_hotz year if year>=1910 & year<=1916, msymb(Dh) msize(medlarge) mcolor(blue*1.2) ) ///
(scatter ch_pWIR_landmann year if year>=1910 & year<=1916, msymb(Sh) msize(medlarge) mcolor(green*1.2) ) ///
(scatter ch_pWIR_fahrlaender year if year>=1910 & year<=1916, msymb(+) msize(large) mcolor(yellow*1.2) ) ///
(scatter ch_pWIR_landmann_no_durable year if year>=1910 & year<=1916, msize(large) msymb(X) mcolor(orange*1.2) ) ///
, title() legend( size(small) ) ytitle(Value of wealth (in % of national income), ) xtitle("") ///
ylab(3 "300%" 4 "400%" 5 "500%" 6 "600%" 7 "700%" 8 "800%" 9 "900%", labsize(small) grid) xlab(1910(1)1916,grid)
graph export "Fig_append_B_3.pdf", replace


*******************************************************************************************************************************

*******************************************************************************************************************************

			

*** To produce Appendix Figure B4  and B5 (comparison of tax revenue across countries) run this do-file which loads the data and produces the figures 
*** For details see the do-file below
cd "$mypath/"
do "6_analysis_wir_append_fig_tax_revenue.do"		
			
***read data 
cd "$mypath/final_data/"
use "WIR_final.dta", clear
cd "$mypath/output/figures/"
			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			

*** Evolution of per capita real private Wealth

tw (connect ch_pW_PC_R year if year>=1995, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
, title() legend(off) ytitle("Real private wealth per capita" "(in thousands of 2020 Swiss francs)") xtitle("") /// 
ylab(200000 "200" 300000 "300" 400000 "400" 500000 "500", labsize(medsmall) grid) xlab(1995(5)2020,grid) ///
ymtick(200000(50000)500000, grid)

graph export "Fig_append_B_6.pdf", replace


			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			
* long run series on a logscale
tw (line ch_nni_PC_R year if year>=1900, connect (direct) lcolor(red*1.0) lpattern(direct) lwidth(medthick) mcolor(red*1.0) msymbol(i))  ///
, title() legend(off) ytitle("Real national income per capita" "(in thousands of 2020 Swiss francs)") xtitle("") /// 
yscale(log) ylab(20000 "20" 40000 "40" 60000 "60" 80000 "80", grid) xlab(1900(20)2020,grid) xmtick(1900(10)2020,grid)

graph export "Fig_append_B_7a.pdf", replace

*** Real National Income per Capita ***
tw (connect ch_nni_PC_R year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
, title() legend(off) ytitle("Real national income per capita" "(in thousands of 2020 Swiss francs)") xtitle("") /// 
ylab(50000 "50" 55000 "55" 60000 "60" 65000 "65" 70000 "70", grid) xlab(1990(10)2020,grid) ///
xmtick(1990(5)2020,grid)

graph export "Fig_append_B_7b.pdf", replace

**

			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			

***** International Comparison *****
*** Label variables
label variable ch_pWIR "Switzerland" 
label variable DE_pWIR_excl_domW_agriW "Germany"
label variable FR_pWIR_excl_domW_agriW "France"
label variable IT_pWIR_excl_domW_agriW "Italy"
label variable SE_pWIR_excl_domW_agriW "Sweden"
label variable US_pWIR_excl_domW_agriW "United States"

*** Private WIR Switzerland, Germany, France, Italy, Sweden, United States exclusive AptDpt

tw (connect ch_pWIR year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect DE_pWIR_excl_domW_agriW year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect FR_pWIR_excl_domW_agriW year if year>=1990, lcolor(blue*1.2) mcolor(blue*1.2) msymb(Th) lpattern(-.-) lwidth(medthick)  ) ///
	(connect IT_pWIR_excl_domW_agriW year if year>=1990, lcolor(green*1.2) mcolor(green*1.2) msymb(Oh) lpattern(-.-) lwidth(medthick)  ) ///
	(connect SE_pWIR_excl_domW_agriW year if year>=1990, lcolor(orange*1.2) mcolor(orange*1.2) msymb(Dh) lpattern(longdash) lwidth(medthick)  ) ///
	(connect US_pWIR_excl_domW_agriW year if year>=1990, lcolor(yellow*1.2) mcolor(yellow*1.2) msymb(D) lpattern(longdash) lwidth(medthick)  ) ///
	, title() legend() ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(2 "200%" 4 "400%" 6 "600%" 8 "800%", grid) ymtick(2(1)8, grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid)

	graph export "Fig_append_B_8.pdf", replace

	
	
	

			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			

***** Housing Wealth *****
***label variables 
label variable ch_pWIR_housing "Switzerland" 
label variable DE_pWIR_housing "Germany"
label variable FR_pWIR_housing "France"
label variable IT_pWIR_housing "Italy"
label variable SE_pWIR_housing "Sweden"
label variable US_pWIR_housing "United States"
 
 *** Housing WIR Switzerland, Germany, France, Italy, Sweden, United States
tw (connect ch_pWIR_housing year if year>=2000, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect DE_pWIR_housing year if year>=2000, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect FR_pWIR_housing year if year>=2000, lcolor(blue*1.2) mcolor(blue*1.2) msymb(Th) lpattern(-.-) lwidth(medthick)  ) ///
	(connect IT_pWIR_housing year if year>=2000, lcolor(green*1.2) mcolor(green*1.2) msymb(Oh) lpattern(-.-) lwidth(medthick)  ) ///
	(connect SE_pWIR_housing year if year>=2000, lcolor(orange*1.2) mcolor(orange*1.2) msymb(Dh) lpattern(longdash) lwidth(medthick)  ) ///
	(connect US_pWIR_housing year if year>=2000, lcolor(yellow*1.2) mcolor(yellow*1.2) msymb(D) lpattern(longdash) lwidth(medthick)  ) ///
	, title() legend() ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(0 "" 1 "100%" 2 "200%" 3 "300%" 4 "400%" 5 "500%", grid) xlab(2000(5)2020,grid)

	graph export "Fig_append_B_9a.pdf", replace
 
 
// share of housing wealth in total private wealth (total private wealth exclusive agricultural land and other domestic private wealth) 
gen ch_housing_sh = ch_pWIR_housing / ch_pWIR
gen de_housing_sh = DE_pWIR_housing / DE_pWIR_excl_domW_agriW 
gen fr_housing_sh = FR_pWIR_housing / FR_pWIR_excl_domW_agriW 
gen it_housing_sh = IT_pWIR_housing / IT_pWIR_excl_domW_agriW 
gen se_housing_sh = SE_pWIR_housing / SE_pWIR_excl_domW_agriW 
gen us_housing_sh = US_pWIR_housing / US_pWIR_excl_domW_agriW 
label variable ch_housing_sh "Switzerland"
label variable de_housing_sh "Germany"
label variable fr_housing_sh "France"
label variable it_housing_sh "Italy"
label variable se_housing_sh "Sweden"
label variable us_housing_sh "United States"


tw (connect ch_housing_sh year if year>=2000, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect de_housing_sh year if year>=2000, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect fr_housing_sh year if year>=2000, lcolor(blue*1.2) mcolor(blue*1.2) msymb(Th) lpattern(-.-) lwidth(medthick)  ) ///
	(connect it_housing_sh year if year>=2000, lcolor(green*1.2) mcolor(green*1.2) msymb(Oh) lpattern(-.-) lwidth(medthick)  ) ///
	(connect se_housing_sh year if year>=2000, lcolor(orange*1.2) mcolor(orange*1.2) msymb(Dh) lpattern(longdash) lwidth(medthick)  ) ///
	(connect us_housing_sh year if year>=2000, lcolor(yellow*1.2) mcolor(yellow*1.2) msymb(D) lpattern(longdash) lwidth(medthick)  ) ///
	, title() legend() ytitle(in % of total private wealth) xtitle("") /// 
	ylab(0.35 "35%" 0.45 "45%" 0.55 "55%" 0.65 "65%" 0.75 "75%", grid) xlab(2000(5)2020,grid)

	graph export "Fig_append_B_9b.pdf", replace




			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  
***** Correction of Public Wealth in Switzerland *****

*** Original Series of non-financial public wealth at the different government-levels
*** label variables
label variable ch_gW_nonfin_bund "Federal-level (original series)"
label variable ch_gW_nonfin_ktn "Cantons"
label variable ch_gW_nonfin_gdn "Municipalities" 	

tw (connect ch_gW_nonfin_bund year if year>=1990, lcolor(red) mcolor(red) lwidth(medthick) ) ///
	(connect ch_gW_nonfin_ktn year if year>=1990, lcolor(black) mcolor(black) msymb(T) lpattern() lwidth(medthick)  ) ///
	(connect ch_gW_nonfin_gdn year if year>=1990, lcolor(navy) mcolor(navy) msymb(D) lpattern() lwidth(medthick)  ) ///
	, title(Non-financial public wealth) legend(label(1 "Federal-level" "(original series)") label(2 "Cantons") label(3 "Municipalities") size(small) rows(1)) ytitle("Nominal value of public wealth" "(in billions Swiss francs)") xtitle("") /// 
	ylab(20000 "20" 40000 "40" 60000 "60" 80000 "80" 100000 "100", grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid)

	graph export "Fig_append_B_10a.pdf", replace

	


*** growth rate of non-financial wealth at the federal level corrected and original series	 
gen ch_gW_nonfin_gr_bund_cor = ch_gW_nonfin_gr_bund if year != 2007 & year != 2008
replace ch_gW_nonfin_gr_bund_cor = ch_gW_nonfin_grmean2[119] if missing(ch_gW_nonfin_gr_bund_cor)
replace ch_gW_nonfin_gr_bund_cor =. if year<=1990
replace ch_gW_nonfin_gr_bund_cor = ch_gW_nonfin_gr_bund_cor - 1
gen ch_gW_nonfin_gr_bund_1 = ch_gW_nonfin_gr_bund - 1 

tw (connect ch_gW_nonfin_gr_bund_1 year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gW_nonfin_gr_bund_cor year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(longdash) lwidth(medthick) ) ///
	, title(Growth rate of non-financial public wealth) legend(label(1 "Federal-level" "(original series)") label(2 "Federal-level" "(corrected series)") size(small)) ytitle("%-change from previous year") xtitle("") ///
	ylab(0"" 0.2 "20%" 0.4 "40%" 0.6 "60%" 0.8 "80%", grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid)

	graph export "Fig_append_B_10b.pdf", replace

	
drop ch_gW_nonfin_gr_bund_cor
		   

*** non-financial public wealth at the federal-levels original vs. corrected series
tw (connect ch_gW_nonfin_bund year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gW_nonfin_bund_cor year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(longdash) lwidth(medthick)  ) ///
	, title(Non-financial public wealth) legend(label(1 "Federal-level" "(original series)") label(2 "Federal-level" "(corrected series)")  size(small)) ytitle("Nominal value of public wealth" "(in billions Swiss francs)") xtitle("") ///
	ylab(20000 "20" 40000 "40" 60000 "60" 80000 "80" 100000 "100", grid)  xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) name(fig_1990, replace)

	graph export "Fig_append_B_10c.pdf", replace

    
*** non-financial gWIR at all government-levels original vs. corrected series
tw (connect ch_gWIR_nonfin_staat year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gWIR_nonfin_staat_cor year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(longdash) lwidth(medthick)  ) ///
	, title(Non-financial public wealth-income ratio) legend(label(1 "all government-levels" "(original series)") label(2 "all government-levels" "(corrected series)")  size(small)) ytitle("Value of wealth (in % of national income)") xtitle("") ///
	ylab(0 "" 0.2 "20%" 0.4 "40%" 0.6 "60%" 0.8 "80%", grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 

	graph export "Fig_append_B_10d.pdf", replace


*** net gWIR  at the goverment-levels original vs. corrected series
tw (connect ch_gWIR_net_staat year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gWIR_net_staat_cor year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(longdash) lwidth(medthick)  ) ///
	, title(Net public wealth-income ratio) legend(label(1 "all government-levels" "(original series)") label(2 "all government-levels" "(corrected series)")  size(small)) ytitle("Value of wealth (in % of national income)") xtitle("") ///
	ylab(0 "" 0.2 "20%" 0.4 "40%" 0.6 "60%" 0.8 "80%", grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 

	graph export "Fig_append_B_10e.pdf", replace
 
 



			
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  

** Public WIR international comparison ***
*** Label variables
label variable ch_gWIR_net_staat_cor "Switzerland"
label variable DE_gWIR "Germany"
label variable FR_gWIR "France"
label variable IT_gWIR "Italy"
label variable SE_gWIR "Sweden"
label variable US_gWIR "United States"

tw (connect ch_gWIR_net_staat_cor year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect DE_gWIR year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect FR_gWIR year if year>=1990, lcolor(blue*1.2) mcolor(blue*1.2) msymb(Th) lpattern(-.-) lwidth(medthick)  ) ///
	(connect IT_gWIR year if year>=1990, lcolor(green*1.2) mcolor(green*1.2) msymb(Oh) lpattern(-.-) lwidth(medthick)  ) ///
	(connect SE_gWIR year if year>=1990, lcolor(orange*1.2) mcolor(orange*1.2) msymb(Dh) lpattern(longdash) lwidth(medthick)  ) ///
	(connect US_gWIR year if year>=1990, lcolor(yellow*1.2) mcolor(yellow*1.2) msymb(D) lpattern(longdash) lwidth(medthick)  ) ///
	, title() legend() ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(-1.5 "-150%" -1.0 "-100%" -0.5 "-50%" 0"" 0.5 "50%" 1 "100%" 1.5 "150%", grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 

	graph export "Fig_append_B_11.pdf", replace
 

*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  

** Main components of public wealth at each goverment-levels
***label variables
label variable ch_gWIR_nonfin_gdn "Non-financial assets"
label variable ch_gWIR_fin_gdn "Financial assets"
label variable ch_gWIR_liab_gdn "Liabilities"
label variable ch_gWIR_nonfin_ktn "Non-financial assets"
label variable ch_gWIR_fin_ktn "Financial assets"
label variable ch_gWIR_liab_ktn "Liabilities"
label variable ch_gWIR_nonfin_bund_cor "Non-financial assets"
label variable ch_gWIR_fin_bund "Financial assets"
label variable ch_gWIR_liab_bund "Liabilities"
label variable ch_gWIR_nonfin_sv "Non-financial assets"
label variable ch_gWIR_fin_sv "Financial assets"
label variable ch_gWIR_liab_sv "Liabilities"  


	
tw (connect ch_gWIR_nonfin_bund_cor year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gWIR_fin_bund year if year>=1990, lcolor(black) mcolor(black) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect ch_gWIR_liab_bund year if year>=1990, lcolor(navy) mcolor(navy) msymb(D) msize(1.3) lpattern() lwidth(medthick)  ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ylab(0 "" 0.1 "10%" 0.2 "20%" 0.3 "30%" 0.4 "40%",grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 
	
	graph export "Fig_append_B_12a.pdf", replace

	
tw (connect ch_gWIR_nonfin_ktn year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gWIR_fin_ktn year if year>=1990, lcolor(black) mcolor(blaci) msymb(T) lpattern() lwidth(medthick)  ) ///
	(connect ch_gWIR_liab_ktn year if year>=1990, lcolor(navy) mcolor(navy) msymb(D) msize(1.3) lpattern() lwidth(medthick)  ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ///
	ylab(0 "" 0.1 "10%" 0.2 "20%" 0.3 "30%" 0.4 "40%",grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 
	
	graph export "Fig_append_B_12b.pdf", replace


tw (connect ch_gWIR_nonfin_gdn year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gWIR_fin_gdn year if year>=1990, lcolor(black) mcolor(black) msymb(T) lpattern() lwidth(medthick)  ) ///
	(connect ch_gWIR_liab_gdn year if year>=1990, lcolor(navy) mcolor(navy) msymb(D) msize(1.3) lpattern() lwidth(medthick)  ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ylab(0 "" 0.05 "5%" 0.1 "10%" 0.15 "15%" 0.2 "20%",grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 
	
	graph export "Fig_append_B_12c.pdf", replace

	
tw (connect ch_gWIR_nonfin_sv year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect ch_gWIR_fin_sv year if year>=1990, lcolor(black) mcolor(black) msymb(T) lpattern() lwidth(medthick)  ) ///
	(connect ch_gWIR_liab_sv year if year>=1990, lcolor(navy) mcolor(navy) msymb(D) msize(1.3) lpattern() lwidth(medthick)  ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ylab(-0.02 "-2%" 0 "" 0.02 "2%" 0.04 "4%" 0.06 "6%" 0.08 "8%" 0.1 "10%" ,grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 
	
	graph export "Fig_append_B_12d.pdf", replace



*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  

*** Label variables
label variable ch_gWIR_net_gdn "Municipalities"
label variable ch_gWIR_net_ktn "Cantons"
label variable ch_gWIR_net_bund_cor "Confederation"
label variable ch_gWIR_net_sv "Social Security Funds"


tw (connect ch_gWIR_net_bund_cor year if year>=1990, lcolor(red) mcolor(red) msymb(O) lpattern() lwidth(medthick)  ) ///
	(connect ch_gWIR_net_ktn year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern() lwidth(medthick)  ) ///
	(connect ch_gWIR_net_gdn year if year>=1990, lcolor(navy) mcolor(navy) msymb(D) msize(1.2) lwidth(medthick) ) ///
	(connect ch_gWIR_net_sv year if year>=1990, lcolor(gray) mcolor(gray) msymb(S) msize(1.2) lpattern() lwidth(medthick)  ) ///
	, title() legend() ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(0 "" 0.1 "10%" 0.2 "20%" 0.3 "30%" 0.4 "40%", grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid) 

	graph export "Fig_append_B_13.pdf", replace



*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  
preserve 
*** imoprt historical public wealth 
cd "$mypath/raw_data/"

import excel "CH_gW_historical.xlsx", sheet("stata") firstrow clear
tempfile CH_gW_hist
save "`CH_gW_hist'"

restore

merge 1:1 year using "`CH_gW_hist'"
drop _merge

cd "$mypath/output/figures/"

gen ch_fs_gWIR_ktn = ch_fs_gW_ktn_netwealth / ch_nni_T
label variable ch_gWIR_net_ktn "GFS Model"
label variable ch_fs_gWIR_ktn "Historical Estimates"
gen ch_gWIR_dif_ktn=ch_gWIR_net_ktn-ch_fs_gWIR_ktn if year==1990
replace ch_gWIR_dif = ch_gWIR_dif_ktn[91] 
gen ch_fs_gWIR_ktn_prolong = ch_fs_gWIR_ktn + ch_gWIR_dif if year>=1930 & year<=1990
label variable ch_fs_gWIR_ktn_prolong "Historical (extrapolated)"



tw (connect ch_gWIR_net_ktn year if year>=1930, lcolor(red*1.0) mcolor(red*1.0) msize(small) lwidth(medthick) ) ///
	(connect ch_fs_gWIR_ktn year if year>=1930, lcolor(black) mcolor(black) msymb(T) msize(small) lpattern() lwidth(medthick)  ) ///
	(line ch_fs_gWIR_ktn_prolong year if year>=1930, lcolor(red*1.0) mcolor(red*1.0)  lpattern(longdash) lwidth(medthick) ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("")  ///
	ylab(-0.1 "-10%" 0.0 "" 0.1 "10%" 0.2 "20%" 0.3 "30%" 0.4 "40%",grid) xlab(1930(10)2020,grid) 

	graph export "Fig_append_B_14a.pdf", replace

	
****bund	
gen ch_fs_gWIR_bnd = ch_fs_gW_bnd_netwealth / ch_nni_T
label variable ch_gWIR_net_bund_cor "GFS Model"
label variable ch_fs_gWIR_bnd "Historical Estimates"
gen ch_gWIR_dif_bnd=ch_gWIR_net_bund_cor[91]-ch_fs_gWIR_bnd[90]
gen ch_fs_gWIR_bnd_prolong = ch_fs_gWIR_bnd + ch_gWIR_dif_bnd if year>=1950 & year<=1989
label variable ch_fs_gWIR_bnd_prolong "Historical (extrapolated)"


tw (connect ch_gWIR_net_bund_cor year if year>=1950, lcolor(red*1.0) mcolor(red*1.0) msize(small) lwidth(medthick) ) ///
	(connect ch_fs_gWIR_bnd year if year>=1950, lcolor(black) mcolor(black) msymb(T) msize(small) lpattern() lwidth(medthick)  ) ///
	(line ch_fs_gWIR_bnd_prolong year if year>=1950, lcolor(red*1.0) mcolor(red*1.0)  lpattern(longdash) lwidth(medthick) ) ///
	, title() legend(row(1) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") xlab(1950(10)2020,grid) ///
	ylab(-0.3 "-30%" -0.2 "-20%" -0.1 "-10%" 0 "" 0.1 "10%" 0.2 "20%",grid)
	
	graph export "Fig_append_B_14b.pdf", replace
	
	

*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  

	
***** Net Foreing WIR International Comparison *****
*** Label variables
label variable ch_nfaWIR_T "Switzerland "
label variable DE_nfaWIR "Germany"
label variable FR_nfaWIR "France"
label variable GB_nfaWIR "United Kingdom"
label variable IT_nfaWIR "Italy"
label variable SE_nfaWIR "Sweden"
label variable US_nfaWIR "United States"

tw (connect ch_nfaWIR_T year if year>=1990, lcolor(red*1.0) mcolor(red*1.0) lwidth(medthick) ) ///
	(connect DE_nfaWIR year if year>=1990, lcolor(black*1.0) mcolor(black*1.0) msymb(T) lpattern(-) lwidth(medthick)  ) ///
	(connect FR_nfaWIR year if year>=1990, lcolor(blue*1.2) mcolor(blue*1.2) msymb(Th) lpattern(-.-) lwidth(medthick)  ) ///
	(connect IT_nfaWIR year if year>=1990, lcolor(green*1.2) mcolor(green*1.2) msymb(Oh) lpattern(-.-) lwidth(medthick)  ) ///
	(connect SE_nfaWIR year if year>=1990, lcolor(orange*1.2) mcolor(orange*1.2) msymb(Dh) lpattern(longdash) lwidth(medthick)  ) ///
	(connect US_nfaWIR year if year>=1990, lcolor(yellow*1.2) mcolor(yellow*1.2) msymb(D) lpattern(longdash) lwidth(medthick)  ) ///
	, title() legend() ytitle(Value of wealth (in % of national income)) xtitle("") /// 
	ylab(-1 "-100%" -0.5 "-50%" 0 "" 0.5 "50%" 1 "100%" 1.5 "150%" , grid) xlab(1990(10)2020,grid) xmtick(1990(5)2020,grid)

	graph export "Fig_append_B_15.pdf", replace



*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  

*** National WIR and Net-foreign WIR
label variable ch_nWIR_T "Domestic wealth"
label variable ch_nfaWIR_T "Net foreign wealth"


mylabels 0(1)8, myscale(@/100) suffix("%") local(myla) // if in format 0.32
tw (area ch_nWIR_T year if year >=1990, color(gs1)) ///
(area ch_nfaWIR_T year if year >=1990, color(gs8)) ///
, xlab (1990(10)2020) ylab(0 "" 1.5 "150%" 3 "300%" 4.5 "450%" 6 "600%" 7.5 "750%" 9 "900%", grid) ytitle("Value of wealth (in % of national income)") xtitle("") xmtick(1990(5)2020, grid)
	
graph export "Fig_append_B_16.pdf", replace
	
*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  

***label Variables
gen ch_pW_grossfin_no_pens_T = ch_pW_liabil_T + ch_pW_netfin_T
gen ch_pWIR_grossfin_no_pens = ch_pW_grossfin_no_pens_T / ch_nni_T
label variable ch_pWIR_grossfin_no_pens "Gross-financial wealth"
label variable ch_pWIR_liabil "Liabilities"
label variable ch_pWIR_pension "Pension wealth"
label variable ch_pWIR_housing "Gross-housing wealth"



tw (connect ch_pWIR_grossfin_no_pens year if year>=2000, lcolor(black) mcolor(black) msymb(T) lwidth(medthick) ) ///
	(connect ch_pWIR_pension year if year>=2000, lcolor(navy) mcolor(navy) msymb(D) msize(1.3) lpattern() lwidth(medthick)  ) ///
	(connect ch_pWIR_housing year if year>=2000, lcolor(red) mcolor(red) msymb(O) lpattern() lwidth(medthick)  ) ///
	(connect ch_pWIR_liabil year if year>=2000, lcolor(gray) mcolor(gray) msymb(S) msize(1.2) lpattern() lwidth(medthick)  ) ///
	, title() legend(row(2) size(small)) ytitle(Value of wealth (in % of national income)) xtitle("") ylab(0 "" 1 "100%" 2 "200%" 3 "300%" 4 "400%", grid) xlab(2000(5)2020,grid)
	
graph export "Fig_append_B_17.pdf", replace
	

*******************************************************************************************************************************			
			
*******************************************************************************************************************************			  

cd "$mypath/"

